package com.example.administrator.wallet.adapter;

import android.app.Activity;
import android.content.Intent;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.wallet.R;
import com.example.administrator.wallet.utils.SharedPrefsUtil;
import com.example.administrator.wallet.view.activity.transaction.BuyActivity;
import com.example.administrator.wallet.view.activity.transaction.SellActivity;

/**
 * Effect:
 * <p>
 * Author:  CaiYapeng
 * <p>
 * Time  :  2018/8/9.
 */
public class TransactionAdapter extends BaseAdapter {
    private Activity context;
    public static int statu=0;

    public TransactionAdapter(FragmentActivity activity) {
        this.context = activity;
    }

    @Override
    public int getCount() {
        return 10;
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if (view == null) {
            holder = new ViewHolder();
            view = View.inflate(context, R.layout.item_trans_list, null);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        holder.user_img = (ImageView) view.findViewById(R.id.user_img);
        holder.user_img = (ImageView) view.findViewById(R.id.coin_icon);
        holder.user_img = (ImageView) view.findViewById(R.id.weixin);
        holder.user_img = (ImageView) view.findViewById(R.id.yihangka);
        holder.user_img = (ImageView) view.findViewById(R.id.zhifubao);
        holder.user_name = (TextView) view.findViewById(R.id.user_name);
        holder.quota_price = (TextView) view.findViewById(R.id.quota_price);
        holder.money = (TextView) view.findViewById(R.id.money);
        holder.submit = (TextView) view.findViewById(R.id.submit);

        if (statu == 0) {
            SharedPrefsUtil.putValue(context,"wallet","select",0);
            holder.submit.setText(context.getString(R.string.buy));
            holder.submit.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent=new Intent(context,BuyActivity.class);
                    context.startActivity(intent);
                }
            });
        } else if (statu == 1) {
            SharedPrefsUtil.putValue(context,"wallet","select",1);
            holder.submit.setText(context.getString(R.string.sell));
            holder.submit.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent=new Intent(context,SellActivity.class);
                    context.startActivity(intent);
                }
            });
        }

        return view;
    }

    static

    private class ViewHolder {
        private ImageView user_img;
        private TextView user_name;
        private TextView quota_price;
        private ImageView coin_icon;
        private ImageView weixin;
        private ImageView yihangka;
        private ImageView zhifubao;
        private TextView money;
        private TextView submit;


    }
}
